import 'package:cbec_app/components/base/base_image.dart';
import 'package:cbec_app/components/base/left_nav_menu_item.dart';
import 'package:cbec_app/components/common/common_style.dart';
import 'package:cbec_app/components/base/base_nav_bar.dart';
import 'package:cbec_app/components/goods/goods_classify_item.dart';
import 'package:cbec_app/entity/simple_entity.dart';
import 'package:cbec_app/utils/logger.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:get/get_core/src/get_main.dart';

///商品分类列表
class GoodsClassifyList extends StatefulWidget {
  ///分类广告信息
  final Map? adInfo;

  ///二级分类列表
  final List<dynamic>? list;

  ///商品分类列表
  const GoodsClassifyList({super.key, this.adInfo, this.list});

  @override
  State<StatefulWidget> createState() => _GoodsClassifyListState();
}

class _GoodsClassifyListState extends State<GoodsClassifyList> {
  double get boxWidth => 247.w;
  @override
  Widget build(BuildContext context) {
    return Container(
        width: boxWidth,
        padding: EdgeInsets.only(right: 8.w),
        child: Column(
          children: [
            ///分类大图
            widget.adInfo!=null&&widget.adInfo?['fileUrl'] != null
                ? BaseImage(
                    url: widget.adInfo!['fileUrl']!,
                    width: boxWidth,
                    height: 106.h,
                    borderRadius: const BorderRadius.all(Radius.circular(8)))
                : emptyWidget(),
            listScroll()
          ],
        ));
  }

  ///listview滚动形式
  Widget listScroll() {
    return Container(
      height:widget.adInfo!=null? 520.h-106.h:520.h,
      child: ListView.builder(
        itemCount: widget.list?.length,
        itemBuilder: (context, index) {
          return GoodsClassifyItem(
            thirdInfo: widget.list?[index]
          );
        },
      ),
    );
  }
}
